<template>
  <div>
    <Mytr :obj="obj" v-for="(obj, index) in goodsArr" :key="index"></Mytr>
    <p>number:{{ isall }}</p>
  </div>
</template>

<script>
// import num from "./components/num";
import Mytr from "./components/num.vue";
export default {
  components: {
    Mytr,
  },
  data() {
    return {
      goodsArr: [
        {
          count: 0,
          goodsName: "Watermelon",
        },
        {
          count: 0,
          goodsName: "Banana",
        },
        {
          count: 0,
          goodsName: "Orange",
        },
        {
          count: 0,
          goodsName: "Pineapple",
        },
        {
          count: 0,
          goodsName: "Strawberry",
        },
      ],
    };
  },
  computed: {
    isall() {
      return this.goodsArr.reduce(
        (sum, item) => (sum += Number(item.count)),
        0
      );
    },
  },
};
</script>

<style>
</style>